<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <base href="http://localhost:8080//bookstore_pro_Web_exploded/">
    <title>Document</title>
    <script src="static/script/jquery-1.7.2.js"></script>
    <link rel="stylesheet" href="static/style/style.css">
</head>
<body>
<div class="login-container">
    <div class="left-container">
        <div class="title"><span>登录</span></div>
        <span style="height: 40px;width: 100px">${requestScope.msg}</span>
        <div class="input-container">
            <input type="text" name="username" value="${requestScope.user.username==null?"":requestScope.user.username}" placeholder="用户名" id="username">
            <input type="password" name="password" vplaceholder="密码" id="password">
        </div>
        <div class="message-container">
            <span>忘记密码</span>
        </div>
    </div>
    <div class="right-container">
        <div class="regist-container">
            <span class="regist"><a href="pages/user/register.jsp">注册</a></span>
        </div>
        <div class="action-container">
            <span>提交</span>
        </div>
    </div>
</div>
</body>
<script>
$(function () {
    $(".action-container>span").click(function () {
        $("#username").empty();
        $("#password").empty();
        var user={
            username:$("#username").val(),
            password:$("#password").val()
        }
        var jsonUser=JSON.stringify(user);
        console.log(jsonUser)
        $.post("UserServlet?action=login",jsonUser,function (data){
            if(data=="200"){
                location.href="index.jsp";
            }
        })
        return false;
        // $.ajax({
        //     url:"UserServlet?action=login&jsonUser="+jsonUser,
        //     type:"get",
        //     data:jsonUser,
        //     contentType: 'application/json;charset=utf-8',
        //     success:function (response,status,xhr) {
        //         console.log(response)
        //         console.log(xhr.status)
        //         if(xhr.status=="300"){
        //             window.location.href="pages/user/login.html"
        //         }
        //         if(xhr.status=="200"){
        //             window.location.href="index.jsp";
        //         }
        //     },
        //     error:function (){
        //         alert("登陆失败！！！");
        //     }
        // })
    })
})

</script>
</html>
